<%@page import="com.google.appengine.api.datastore.DatastoreServiceFactory"%>
<%@page import="com.google.appengine.api.datastore.DatastoreService"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@page import="com.google.appengine.api.datastore.EntityNotFoundException"%>
<%@page import="java.util.ArrayList" %>
<%@page import="javax.servlet.http.HttpSession" %>
<%@page import="nl.project.data.Student" %>
<%@page import="nl.project.data.Parent" %>
<%@page import="nl.project.data.Employee" %>
<%@page import="nl.project.data.controller.MembersDAO" %>
<%@page import="com.google.appengine.api.datastore.DatastoreService"%>
<%@page	import="com.google.appengine.api.datastore.DatastoreServiceFactory"%>
<%@page import="com.google.appengine.api.datastore.Entity"%>
<%@page	import="com.google.appengine.api.datastore.EntityNotFoundException"%>
<%@page import="com.google.appengine.api.datastore.FetchOptions"%>
<%@page import="com.google.appengine.api.datastore.Key"%>
<%@page import="com.google.appengine.api.datastore.KeyFactory"%>
<%@page import="com.google.appengine.api.datastore.Query"%>
<%@page	import="com.google.appengine.api.datastore.Query.FilterOperator"%>
<%@page import="java.util.List"%>
<%@page	import="java.lang.Exception"%>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

		<title>Selectie leerling</title>
		<link rel="stylesheet" type="text/css" href="/include/style.css" />
	</head>
	<body>
		<jsp:include page="include/header.jsp" />
			
		
		<form action="/statsSelect.jsp" method="POST">
		zoek op student nummer: <input type="text" name="student_nummer"/><input type="submit" value="ZOEK"/>
		</form>
		
		<%
		DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
		try{
		int sn = Integer.parseInt( request.getParameter("student_nummer"));
		
		Key Skey = KeyFactory.createKey("Students", "Students");
		Query Sq = new Query("Student", Skey).addFilter("studentId", Query.FilterOperator.EQUAL , String.valueOf(sn) );
		List<Entity> Sl = ds.prepare(Sq).asList(FetchOptions.Builder.withDefaults());
		
		Query Cq = new Query("vak", Sl.get(0).getKey());
		List<Entity> Cl = ds.prepare(Cq).asList(FetchOptions.Builder.withDefaults());
		
		%>
		
		<br><b><%=Sl.get(0).getProperty("surName") %> , <%=Sl.get(0).getProperty("firstName") %></b>
		
		<form action="/StudentStat.jsp" method="POST">
		<input value="<%=sn%>" type="hidden" name="sn"/>
		
		Welke vak wilt u inspecteren : 
		<select name="classes">
		<% for(int i = 0 ; i < Cl.size() ; i++){ %>
		<option value="<%=Cl.get(i).getProperty("courseCode")%>"> <%=Cl.get(i).getProperty("courseName")%></option>
		<%} 
		}catch(Exception e){
			out.println("<b>Student niet gevonden</b>");
		}
		%>		
		</select>
		<input type="submit" value="Inspecteer"/>
		<br>
		<br>
		</form>
		<br>
		<br>
		Bekijk hier de klassen indeling:
		
		<form action="/classStat.jsp" method="post">
		<input type="submit" value="Klassen"/>
		</form>
		
		
</body>
</html>